﻿var errHideTimeOut;
var userMenuTimeOut;
var USER_TOO_SHORT = '用户名不能低于四位';
var PWD_TOO_SHORT = '密码不能低于四位';
var PWD_CONFIRM_FAILED = '密码确认失败';
var EMAIL_FORMAT_ERROR =	'邮件格式错误';
function createxmlhttp()
{
	var xmlhttp=false;
	try	{
  		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
 	} 
	catch (e) {
  		try {
   			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
  		} 
		catch (e) {
   			xmlhttp = false;
 		}
 	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
  		xmlhttp = new XMLHttpRequest();
				if (xmlhttp.overrideMimeType) {//设置MiME类别
			xmlhttp.overrideMimeType('text/xml');
		}
	}	

	return xmlhttp;	
}
(function($){
	$.getStringLength=function(str)
	{
		str = $.trim(str);
		
		if(str=="")
			return 0; 
			
		var length=0; 
		for(var i=0;i <str.length;i++) 
		{ 
			if(str.charCodeAt(i)>255)
				length+=2; 
			else
				length++; 
		}
		
		return length;
	}
	
	$.getLengthString=function(str,length,isSpace)
	{
		if(arguments.length < 3)
			var isSpace = true; 
		
		if($.trim(str)=="")
			return "";
		
		var tempStr="";
		var strLength = 0;
		
		for(var i=0;i <str.length;i++) 
		{
			if(str.charCodeAt(i)>255)
				strLength+=2;
			else
			{
				if(str.charAt(i) == " ")
				{
					if(	isSpace)
						strLength++;	
				}
				else
					strLength++;
			}
				
			if(length >= strLength)
				tempStr += str.charAt(i);
		}
		
		return tempStr;
	}
	
	$.getBodyScrollTop=function(){
        var scrollPos; 
        if (typeof window.pageYOffset != 'undefined') { 
            scrollPos = window.pageYOffset; 
        } 
        else if (typeof document.compatMode != 'undefined' && 
            document.compatMode != 'BackCompat') { 
            scrollPos = document.documentElement.scrollTop; 
        } 
        else if (typeof document.body != 'undefined') { 
            scrollPos = document.body.scrollTop; 
        } 
        return scrollPos;
    }
	
	$.copyText = function(id)
	{
		var txt = $(id).val();
		if(window.clipboardData)
		{
			window.clipboardData.clearData();
			var judge = window.clipboardData.setData("Text", txt);
			if(judge === true)
				alert("复制成功,你可以粘帖到QQ或者MSN的中发给好友！");
			else
				alert("不允许复制，请您手动进行");
		}
		else if(navigator.userAgent.indexOf("Opera") != -1)
		{
			window.location = txt;
		} 
		else if (window.netscape) 
		{
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch(e)
			{
				alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
			}
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip)
				return;
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if (!trans)
				return;
			trans.addDataFlavor('text/unicode');
			var str = new Object();
			var len = new Object();
			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
			var copytext = txt;
			str.data = copytext;
			trans.setTransferData("text/unicode",str,copytext.length*2);
			var clipid = Components.interfaces.nsIClipboard;
			if (!clip)
				return false;
			clip.setData(trans,null,clipid.kGlobalClipboard);
			alert("复制成功,你可以粘帖到QQ或者MSN的中发给好友！");
		}
	};
	
	$(window).scroll(function(){
		if($("#sysmsg-error") != "none" || $("#sysmsg-success") != "none")
		{
			var top = $.getBodyScrollTop();
			if(top < 157)
				top = 157;
			$("#sysmsg-error-box").stop();
			$("#sysmsg-error-box").animate({"top":top},{duration:300}); 
		}
	});
	
	$.showErr = function(str)
	{
		var top = $.getBodyScrollTop();
		if(top < 157)
			top = 157;
		$("#sysmsg-error-box").css({"top":top});
		$("#sysmsg-error span:first").html(str);
		$("#sysmsg-error").show();
		$("#sysmsg-success").hide();
		$("#sysmsg-error-box").show();
		
		clearTimeout(errHideTimeOut);
		
		var hideErr = function(){
			$("#sysmsg-error-box").slideUp(300);
		};
		
		errHideTimeOut = setTimeout(hideErr,3000);
		
		$("#sysmsg-error-box .close").one("click", function(){
			$("#sysmsg-error-box").hide();
		});
	}
	$.showRight = function(str)
	{
		var top = $.getBodyScrollTop();
		if(top < 157)
			top = 157;
		$("#sysmsg-error-box").css({"top":top});
		$("#sysmsg-success span:first").html(str);
		$("#sysmsg-error").hide();
		$("#sysmsg-success").show();
		$("#sysmsg-error-box").show();
		
		clearTimeout(errHideTimeOut);
		
		var hideErr = function(){
			$("#sysmsg-error-box").slideUp(300);
		};
		errHideTimeOut = setTimeout(hideErr,3000);
		$("#sysmsg-error-box .close").one("click", function(){
			$("#sysmsg-error-box").hide();
		});
	}
	$.minLength = function(value, length , isByte) {
		var strLength = $.trim(value).length;
		if(isByte)
			strLength = $.getStringLength(value);
			
		return strLength >= length;
	};
	
	$.maxLength = function(value, length , isByte) {
		var strLength = $.trim(value).length;
		if(isByte)
			strLength = $.getStringLength(value);
			
		return strLength <= length;
	};
	
	$.rangeLength = function(value, minLength,maxLength, isByte) {
		var strLength = $.trim(value).length;
		if(isByte)
			strLength = $.getStringLength(value);
			
		return length >= minLength && length <= maxLength;
	}
	
	$.checkMobilePhone = function(value){
		return /^(13\d{9}|18\d{9}|15\d{9})$/i.test($.trim(value));
	}
	
	$.checkPhone = function(val){
  		var flag = 0;
		val = $.trim(val);
  		var num = ".0123456789/-()";
  		for(var i = 0; i < (val.length); i++)
		{
    		tmp = val.substring(i, i + 1);
    		if(num.indexOf(tmp) < 0)
      			flag++;
 		}
  		if(flag > 0)
			return true;
		else
			return false;
	}
	
	$.checkEmail = function(val){
		return /^((([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+(\.([a-z]|\d|[!#\$%&'\*\+\-\/=\?\^_`{\|}~]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])+)*)|((\x22)((((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(([\x01-\x08\x0b\x0c\x0e-\x1f\x7f]|\x21|[\x23-\x5b]|[\x5d-\x7e]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(\\([\x01-\x09\x0b\x0c\x0d-\x7f]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF]))))*(((\x20|\x09)*(\x0d\x0a))?(\x20|\x09)+)?(\x22)))@((([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|\d|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.)+(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])|(([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])([a-z]|\d|-|\.|_|~|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])*([a-z]|[\u00A0-\uD7FF\uF900-\uFDCF\uFDF0-\uFFEF])))\.?$/i.test(val);
	};
	
})(jQuery);

jQuery(function($){
	$("#subscribe-other").click(function(){
		$("#enter-address-city").show();						 
		$("#subscribecityid").hide();						 
		$("#subscribe-other").hide();
		$("#selectcity").val("1");
	});							
	
	$("#tip-deal-subscribe-body form,#deal-subscribe-body form").submit(function(){
		var thisform = $(this).parent();
		var email = $.trim($("#subscribeemail",this).val());
		var selectcity =$.trim($("#selectcity",this).val());
		var cityID = $.trim($("#subscribecityid",this).val());
		if(email.length == 0 || email=="请输入您的Email...")
		{
			alert("对不起，请输入您的 Email 地址！");
			$("#subscribeemail",this).focus();
			return false;
		}
		if(!$.checkEmail(email))
		{
			alert("对不起，您输入了错误的 Email 地址！");
			$("#subscribeemail",this).focus();
			return false;
		}
		var cityname =$.trim($("#enter-address-city",this).val());
		if(selectcity=="1"){
			if(cityname.length == 0 || cityname=="输入城市名...")
			{
				alert("对不起，请输入订阅城市！");
				$("#enter-address-city",this).focus();
				return false;
			}
		}
	
		$.ajax({
			  url: baseurl+"request.aspx?action=ding&email="+email+"&cityid="+cityID+"&chrcity="+escape(cityname),
			  cache: false,
			  success:function(data)
			  {
				if(data=="0"){
					if(selectcity=="1"){
						if(document.getElementById("showhiddentitle"))	
						{
							document.getElementById("showhiddentitle").innerHTML="提交成功";
						}
						if(document.getElementById("showhiddencontent"))
						{
							document.getElementById("showhiddencontent").innerHTML="<div class=\"succ\">感谢您提供城市信息，这将成为我们选择下一步开通哪个城市的依据。</div>";
						}	
					}
					else{
						var hiddendata =$("#subscribe").val();
						if(hiddendata=="0"){
							if(document.getElementById("tip-deal-subscribe-body")){
								document.getElementById("tip-deal-subscribe-body").innerHTML="您已经成功订阅！";	
							}
							document.getElementById("deal-subscribe-body").innerHTML="您已经成功订阅！";
						}
						else{
							var tt=document.getElementById("subscribecityid").options[window.document.getElementById("subscribecityid").selectedIndex].text	
							if(document.getElementById("showhiddentitle"))	
							{
								document.getElementById("showhiddentitle").innerHTML="订阅成功";
							}
							if(document.getElementById("showhiddencontent"))
							{
								document.getElementById("showhiddencontent").innerHTML="<div class=\"succ\">您的邮箱 <strong>"+email+"</strong> 将会收到<strong>"+tt+"</strong>每天最新的团购信息。</div>";
							}
							
						}
					}
				}
				else{
					alert(data);
				}
			  }
		});
		return false;													  
	});
	
	$("#tip-deal-subscribe-body .f-text,#deal-subscribe-body .f-text").val("请输入您的Email...");
	
	$("#tip-deal-subscribe-body .f-text,#deal-subscribe-body .f-text").focus(function(){
		if($.trim(this.value) == "请输入您的Email...")
			this.value = "";
			
	}).blur(function(){
		if($.trim(this.value) == "")
			this.value = "请输入您的Email...";												  
	});
	$("#credit-card-link").click(function(){
		$("#credit-card-enter").show();
	});		
	$("#deal-share-im").click(function(){
		if($("#deal-share-im-c").css("display") == "none")
		{
			$("#deal-share-im-c").show();
		}else{
			$("#deal-share-im-c").hide();	
		}
	});		
	$("#guides-city-change").click(function(){
		if($("#guides-city-list").css("display") == "none")
		{
			$("#guides-city-list").show();
			$("body").one("click", function(){
				$("#guides-city-list").hide();
			}); 
		}
		else
			$("#guides-city-list").hide();
		return false;
	});
	$("#myaccount").hover(function(){
		$(this).addClass("hover");
		$("#myaccount-menu").show();		   
	},function(){
		var menuHide = function(){
			$("#myaccount").removeClass("hover");
			$("#myaccount-menu").hide();
		};
		userMenuTimeOut = setTimeout(menuHide,100);
	});
	$("#myaccount-menu").hover(function(){
		clearTimeout(userMenuTimeOut);
		$("#myaccount").addClass("hover");   
	},function(){
		$("#myaccount").removeClass("hover");
		$(this).hide();
	});
	$("#signup-city").change(function(){
		if(this.value == 0)
			$(".enter-city").show();
		else
			$(".enter-city").hide();
	});
	/*if($("#creditmoney").val()=="0"){
		$("#order-list").hide();
	}*/
	$('#share-copy-button').click(function(){
		$.copyText('#share-copy-text');
	});
	
	$('#share-copy-text').click(function(){
		$.copyText('#share-copy-text');
	});
	
	$("#enter-address-city").focus(function(){
		var address = $.trim($("#enter-address-city").val());
		if(address == "输入城市名...")
			$("#enter-address-city").val("");
	}).blur(function(){
		var address = $.trim($("#enter-address-city").val());
		if(address == "输入城市名..." || address == "")
			$("#enter-address-city").val("输入城市名...");
	});
	
	$("#login-submit").click(function(){
		if($.trim($("#login-email-address").val()).length == 0)
		{
			$.showErr("请输入您的 "+showname+"");
			$("#login-email-address").focus();
			return false;
		}
		if(showname=="Email"){
			if(!$.checkEmail($("#login-email-address").val()))
			{
				$.showErr("您输入了错误的 Email 地址");
				$("#login-email-address").focus();
				return false;
			}
		}
		if(!$.minLength($("#login-password").val(),4,false))
		{
			$.showErr("请输入正确的密码");
			$("#login-password").focus();
			return false;
		}
		var chrpwd=$("#login-password").val();
		alert(chrpwd);
		var tt="1";
		if($("input[name='auto_login']:checked").val()!="1"){
			tt="0";	
		}
		//checklogin(chremail,chrpwd,tt,refurl);
//		if($("#buytuangouid").val()!="1")
//		{
//			return false;
//		}
	});
	$("#signup-submit").click(function(){
		var chremail=$.trim($("#signup-email-address").val());
		if(chremail.length == 0)
		{
			$.showErr("请输入了您的 Email 地址");
			$("#signup-email-address").focus();
			return false;
		}
		var tt="1";
		if($("input[name='subscribe']:checked").val()!="1"){
			tt="0";	
		}
		if(!$.checkEmail($("#signup-email-address").val()))
		{
			$.showErr("您输入了错误的 Email 地址");
			$("#signup-email-address").focus();
			return false;
		}
		
		var chrname=$("#signup-username").val();
		if(!$.minLength($("#signup-username").val(),4,true))
		{
			$.showErr("用户名太短，至少4个字符或2个汉字");
			$("#signup-username").focus();
			return false;
		}
		if(!$.maxLength($("#signup-username").val(),16,true))
		{
			$.showErr("用户名太长，最多16个字符或8个汉字");
			$("#signup-username").focus();
			return false;
		}
		
		var chrpwd=$("#signup-password").val();
		if(!$.minLength($("#signup-password").val(),4,false))
		{
			$.showErr("密码太短，至少4个字符");
			$("#signup-password").focus();
			return false;
		}
		if($("#signup-password-confirm").val() != $("#signup-password").val())
		{
			$.showErr("密码跟确认密码不一致");
			$("#signup-password-confirm").focus();
			return false;
		}

		//checkregister(chremail,cityid,chrcity,chrpwd,chrname,tt,ziduan1,ziduan2,ziduan3,ziduan4,ziduan5);
	    //return true;
		alert("finish");
	});
	
	$("#settings-submit").click(function(){
		if(!$.minLength($("#settings-username").val(),4,true))
		{
			$.showErr("用户名太短，至少4个字符或2个汉字");
			$("#settings-username").focus();
			return false;
		}
		var chrname=$.trim($("#settings-username").val());
		if(!$.maxLength($("#settings-username").val(),16,true))
		{
			$.showErr("用户名太长，最多16个字符或8个汉字");
			$("#settings-username").focus();
			return false;
		}
		if($.trim($("#settings-password").val()).length > 0)
		{
			if(!$.minLength($("#settings-password").val(),4,false))
			{
				$.showErr("密码太短，至少4个字符");
				$("#settings-password").focus();
				return false;
			}
			
			if($("#settings-password-confirm").val() != $("#settings-password").val())
			{
				$.showErr("密码跟确认密码不一致");
				$("#settings-password-confirm").focus();
				return false;
			}
		}
		var chrpwd=$.trim($("#settings-password").val());
		if($.trim($("#settings-mobile").val()).length > 0)
		{
			if(!$.checkMobilePhone($("#settings-mobile").val()))
			{
				$.showErr("请输入正确的11位手机号码");
				$("#settings-mobile").focus();
				return false;
			}
		}
		var chrmobile=$.trim($("#settings-mobile").val());
		var ziduan1=$("#user_pwd_ziduan1").val();
		var ziduan2=$("#user_pwd_ziduan2").val();
		var ziduan3=$("#user_pwd_ziduan3").val();
		var ziduan4=$("#user_pwd_ziduan4").val();
		var ziduan5=$("#user_pwd_ziduan5").val();
		changepwd(chrname,chrmobile,chrpwd,ziduan1,ziduan2,ziduan3,ziduan4,ziduan5);
		return false;
	});
	$("#consult-add-more").click(function(){
		$("#consult-add-succ").hide();
		$(".f-textarea").val("");
		$("#consult-add-form").show();
	});	
	$("#messagesumit").click(function(){
		var chrtitle=$.trim($("#qusstion").val());
		var styleid=$.trim($("#messagestyleid").val());
		var cname="问题";
		if(styleid=="1"){
			cname="信息";	
		}
		if(chrtitle.length == 0)
		{
			$.showErr("请输入"+cname+"!");
			alert("请输入"+cname+"!");
			$("#qusstion").focus();
			return false;
		}
		submitrequest(chrtitle,styleid);
		return false;
	});	
	$("#resetpwdbutton").click(function(){
		var chremail=$.trim($("#reset-email").val());
		if(chremail.length == 0)
		{
			$.showErr("请输入了您的 Email 地址");
			$("#reset-email").focus();
			return false;
		}
		if(!$.checkEmail($("#reset-email").val()))
		{
			$.showErr("您输入了错误的 Email 地址");
			$("#reset-email").focus();
			return false;
		}
		submitforpwd(chremail);
		return false;
	});	
	$("#resetpwdsubbmit").click(function(){
		var chrpwd=$("#reset-password").val();
		if(!$.minLength($("#reset-password").val(),4,false))
		{
			$.showErr("密码太短，至少4个字符");
			$("#reset-password").focus();
			return false;
		}
		
		if($("#reset-password2").val() != $("#reset-password").val())
		{
			$.showErr("密码跟确认密码不一致");
			$("#reset-password2").focus();
			return false;
		}
		var chrcode=$("#resetcode").val();
		submiteditpwd(chrpwd,chrcode);
		return false;
	});	
	$("#feedback-submit").click(function(){
		var chrname=$("#feedback-fullname").val();
		if(!$.minLength($("#feedback-fullname").val(),2,false))
		{
			$.showErr("请输入您的称呼!");
			$("#feedback-fullname").focus();
			return false;
		}
		if($("#feedback-email-address").val().length == 0)
		{
			$.showErr("请输入联系方式");
			$("#feedback-email-address").focus();
			return false;
		}
		var tt=$("#feedback-styleid").val();
		var msg="团购信息";
		if(tt=="0"){
			msg="反馈内容";	
		}
		var chrtel=$("#feedback-email-address").val();
		if($("#feedback-suggest").val().length == 0)
		{
			$.showErr("请输入"+msg);
			$("#feedback-suggest").focus();
			return false;
		}
		var chrmark=$("#feedback-suggest").val();
		var othertel=$("#feedback-mobile").val();
		var cityid=$("#feedback-city").val();
		var chrcompany=$("#feedback-bizname").val();
		var leixing=$("#feedback-category").val();
		
		submitfeedback(chrname,chrtel,chrmark,tt,othertel,cityid,chrcompany,leixing);
		return false;
	});	
	$("#credit-card-cancel").click(function(){
		$("#credit-card-enter").hide();
	});	
	$("#credit-card-submit").click(function(){
		var shu=$("#credit-card-text").val();
		if($("#credit-card-text").val().length == 0)
		{
			$.showErr("对不起，请输入充值卡!");
			$("#credit-card-text").focus();
			return false;
		}
		submitcreditcard(shu);
		return false;
	});	
	$("#deal-orderbybuy-form").click(function(){
		var flag=true;
		var quantitys = $(".order-table").find("#deal-buy-quantity-input");
		for(var i=0;i<quantitys.length;i++)
		{
			if(parseInt(quantitys[i].value)>0){
				flag=false;	
			}
		}
		if(flag){
			$.showErr("对不起，购买数量不能为0!");
			return false;
		}
		if($("#styleid").val()=="3")
		{
			var _82=$("#address-name-error");
			var _83=$("#address-name");
			var _89="请正确填写联系人，最少不能低于2个字，最多不能超过15个字";
			if(!_83.val()||_83.val().length<2 || _83.val().length>15)
			{
				_82.html(_89);
				_82.show();
				return false;
			}
			var _82=$("#address-phone-error");
			var _83=$("#address-phone");
			var _89="电话号码不能少于6位";
			if(!_83.val()||!_83.val().match(/^.{6,}$/))
			{
				_82.html(_89);
				_82.show();
				return false;
			}
		}
		var ziti=$("input[name='shuohuostyleid']:checked").val();
		if($("#isaddress").val()=="1" && ziti=="0")
		{
			var _82=$("#address-district-error");
			var _83=$("#address-zipcode");
			var _89="邮政编码填写有误,请输入6位邮政编码";
			if(!_83.val()||!_83.val().match(/^\d{6}$/))
			{
				_82.html(_89);
				_82.show();
				return false;
			}
			var _82=$("#address-detail-error");
			var _83=$("#address-detail");
			var _89="请填写街道地址，最少5个字，最多不能超过60个字，不能全部为数字";
			if(!_83.val()||_83.val().length<5 ||_83.val().length>60)
			{
				_82.html(_89);
				_82.show();
				return false;
			}
			var _82=$("#address-name-error");
			var _83=$("#address-name");
			var _89="请正确填写姓名，最少不能低于2个字，最多不能超过15个字";
			if(!_83.val()||_83.val().length<2 || _83.val().length>15)
			{
				_82.html(_89);
				_82.show();
				return false;
			}
			var _82=$("#address-phone-error");
			var _83=$("#address-phone");
			var _89="电话号码不能少于6位";
			if(!_83.val()||!_83.val().match(/^.{6,}$/))
			{
				_82.html(_89);
				_82.show();
				return false;
			}
			
		}
	});
	$("#address-zipcode").blur(function () { 
		return checkZipcode();
	});
	$("#address-detail").blur(function () { 
		return checkDetail();
	});
	$("#address-name").blur(function () { 
		return checkName();
	});
	$("#address-phone").blur(function () { 
		return checkPhone();
	});
	$("#tuangou-order").click(function(){
		if(!$.checkMobilePhone($("#deal-buy-mobile-input").val()))
		{
			$.showErr("请输入正确的11位手机号码");
			$("#deal-buy-mobile-input").focus();
			return false;
		}
		var orderid=$("#deal-buy-orderid").val();
		var chrmobile=$("#deal-buy-mobile-input").val();
		submitchrmobileorder(orderid,chrmobile);
		return false;
	});	
	$("#fasong_shouji_submit").click(function(){
		if(!$.checkMobilePhone($("#deal-buy-mobile-input").val()))
		{
			$.showErr("请输入正确的11位手机号码");
			$("#deal-buy-mobile-input").focus();
			return false;
		}
		var orderid=$("#deal-buy-orderid").val();
		var chrmobile=$("#deal-buy-mobile-input").val();
		submitquanmobile(orderid,chrmobile);
		return false;
	});	
	$("#account-charge-form").submit(function(){
		var _28=$("#account-charge-money");
		var _2a=/^[\d\.]+$/;
		if(!_28.val() ){
			$.showErr("\u5145\u503c\u91d1\u989d\u4e0d\u80fd\u4e3a\u7a7a");
			_28.focus();
			return false;
		}
		else{
			if(!_2a.test(_28.val())||_28.val()<0.01 ){
				$.showErr("\u8bf7\u8f93\u5165\u6b63\u786e\u7684\u5145\u503c\u91d1\u989d");
				_28.focus();
				return false;
			}
			else if( _28.val()>=500){
				$.showErr("\u63d0\u793a\uff1a\u5145\u503c\u91d1\u989d\u8d85\u51fa\u90e8\u5206\u94f6\u884c\u5355\u7b14\u652f\u4ed8\u989d\u5ea6\uff0c\u5efa\u8bae\u6bcf\u6b21\u5145\u503c\u5c0f\u4e8e499\u5143");
				_28.focus();
				return false;
			}
		}
	});	
	$("#account-points-form").submit(function(){
		var _28=$("#account-points-money");
		var _2a=/^[\d\.]+$/;
		if(!_28.val() ){
			$.showErr("对不起，请输入兑换积分！");
			_28.focus();
			return false;
		}
		else{
			if(!_2a.test(_28.val())||_28.val()<1 ){
				$.showErr("对不起，请输入正确的兑换积分！");
				_28.focus();
				return false;
			}
			else if( _28.val()>$("#points_myjifen").val()){
				var _2c=parseInt($("#points_myjifen").val());
				var tip="对不起：您的可用积分是"+_2c+"，兑换积分数不能大于您的可用积分！";
				$.showErr(tip);
				_28.focus();
				return false;
			}
		}
	});	
	$("#pay-submiti").click(function () { 
		var id=$("#pay_orderid").val();
		var url="";
		if(window.location.href.indexOf(":8700")!=-1){
		    url="/learn";
		}
		var url1=url+"/account/pay/"+id+"/";
		url +="/payorder/"+id+".html";
		var innerHTML="<div id='order-pay-dialog'><div class=\"order-pay-dialog-c\"><h3><span id=\"order-pay-dialog-close\" class=\"close\" onclick=\"$('#dialog').hide();$('#pagemasker').hide();\">\u5173\u95ed</span></h3><p class=\"info\">\u8bf7\u60a8\u5728\u65b0\u6253\u5f00\u7684\u9875\u9762\u4e0a<br />\u5b8c\u6210\u4ed8\u6b3e\u3002</p><p class=\"notice\">\u4ed8\u6b3e\u5b8c\u6210\u524d\u8bf7\u4e0d\u8981\u5173\u95ed\u6b64\u7a97\u53e3\u3002<br />\u5b8c\u6210\u4ed8\u6b3e\u540e\u8bf7\u6839\u636e\u60a8\u7684\u60c5\u51b5\u70b9\u51fb\u4e0b\u9762\u7684\u6309\u94ae\uff1a</p><p class=\"act\"><input id=\"order-pay-dialog-succ\" type=\"submit\" class=\"formbutton\" value=\"\u5df2\u5b8c\u6210\u4ed8\u6b3e\" onclick=\"location.href='"+url+"';\"/> <input id=\"order-pay-dialog-fail\" type=\"submit\" class=\"formbutton\" value=\"\u4ed8\u6b3e\u9047\u5230\u95ee\u9898\" onclick=\"location.href='"+url+"';\"/></p><p class=\"retry\"><a href=\""+url1+"\">&raquo; \u8fd4\u56de\u9009\u62e9\u5176\u4ed6\u652f\u4ed8\u65b9\u5f0f</a></p></div></div>";
		var dialog=$('#dialog');
		dialog.html(innerHTML);
 		var ew=340;var ww=jQuery(window).width();var lt=(ww/2-ew/2)+'px';var tp='20%';dialog.css('background-color','#FFF');dialog.css('left',lt);dialog.css('top',tp);dialog.css('z-index',9999);dialog.css('display','block');
		var height=jQuery('body').height()+'px';
		var width=jQuery(window).width()+'px';jQuery('#pagemasker').css({'position':'absolute','z-index':'3000','width':width,'height':height,'filter':'alpha(opacity=0.2)','opacity':0.2,'top':0,'left':0,'background':'#C0C0C0','display':''});
		//return false;
	}); 
	
	
	$("#pay-submiticharget").click(function () { 
		var url="";
		if(window.location.href.indexOf(":8700")!=-1){
		    url="/learn";
		}
		var url1=url+"/account/credit/";
		url +="/account/charge/";
		var innerHTML="<div id='order-pay-dialog'><div class=\"order-pay-dialog-c\"><h3><span id=\"order-pay-dialog-close\" class=\"close\" onclick=\"$('#dialog').hide();$('#pagemasker').hide();\">\u5173\u95ed</span></h3><p class=\"info\">\u8bf7\u60a8\u5728\u65b0\u6253\u5f00\u7684\u9875\u9762\u4e0a<br />\u5b8c\u6210\u4ed8\u6b3e\u3002</p><p class=\"notice\">\u4ed8\u6b3e\u5b8c\u6210\u524d\u8bf7\u4e0d\u8981\u5173\u95ed\u6b64\u7a97\u53e3\u3002<br />\u5b8c\u6210\u4ed8\u6b3e\u540e\u8bf7\u6839\u636e\u60a8\u7684\u60c5\u51b5\u70b9\u51fb\u4e0b\u9762\u7684\u6309\u94ae\uff1a</p><p class=\"act\"><input id=\"order-pay-dialog-succ\" type=\"submit\" class=\"formbutton\" value=\"\u5df2\u5b8c\u6210\u4ed8\u6b3e\" onclick=\"location.href='"+url1+"';\"/> <input id=\"order-pay-dialog-fail\" type=\"submit\" class=\"formbutton\" value=\"\u4ed8\u6b3e\u9047\u5230\u95ee\u9898\" onclick=\"location.href='"+url1+"';\"/></p><p class=\"retry\"><a href=\""+url+"\">&raquo; \u8fd4\u56de\u9009\u62e9\u5176\u4ed6\u652f\u4ed8\u65b9\u5f0f</a></p></div></div>";
		var dialog=$('#dialog');
		dialog.html(innerHTML);
 		var ew=340;var ww=jQuery(window).width();var lt=(ww/2-ew/2)+'px';var tp='20%';dialog.css('background-color','#FFF');dialog.css('left',lt);dialog.css('top',tp);dialog.css('z-index',9999);dialog.css('display','block');
		var height=jQuery('body').height()+'px';
		var width=jQuery(window).width()+'px';jQuery('#pagemasker').css({'position':'absolute','z-index':'3000','width':width,'height':height,'filter':'alpha(opacity=0.2)','opacity':0.2,'top':0,'left':0,'background':'#C0C0C0','display':''});
		//return false;
	}); 
	
	$("#companysignup-submit").click(function(){
		var chrname=$("#signup-username").val();
		if(!$.minLength($("#signup-username").val(),2,true))
		{
			$.showErr("用户名太短，至少2个字符或1个汉字");
			$("#signup-username").focus();
			return false;
		}
		if(!$.maxLength($("#signup-username").val(),16,true))
		{
			$.showErr("用户名太长，最多16个字符或8个汉字");
			$("#signup-username").focus();
			return false;
		}
		var chrpwd=$("#signup-password").val();
		if(!$.minLength($("#signup-password").val(),4,false))
		{
			$.showErr("密码太短，至少4个字符");
			$("#signup-password").focus();
			return false;
		}
		if($("#signup-password-confirm").val() != $("#signup-password").val())
		{
			$.showErr("密码跟确认密码不一致");
			$("#signup-password-confirm").focus();
			return false;
		}
		var chrcompany=$("#signup-chrcompany").val();
		if(chrcompany==""){
			$.showErr("公司名称不能为空！");
			$("#signup-chrcompany").focus();
			return false;
		}
		var chrtel=$("#signup-chrtel").val();
		if(chrtel==""){
			$.showErr("联系电话不能为空！");
			$("#signup-chrtel").focus();
			return false;
		}
		//checkcompanyregister(chrname,chrpwd,chrcompany,chrtel);
		return true;
	});
	
	$("#companylogin-submit").click(function(){
		if($.trim($("#login-email-address").val()).length == 0)
		{
			$.showErr("请输入您的用户名");
			$("#login-email-address").focus();
			return false;
		}
		var chrname=$.trim($("#login-email-address").val());
		if(!$.minLength($("#login-password").val(),4,false))
		{
			$.showErr("请输入正确的密码");
			$("#login-password").focus();
			return false;
		}
		var chrpwd=$("#login-password").val();
		var tt="1";
		if($("input[name='auto_login']:checked").val()!="1"){
			tt="0";	
		}
		//checkcompanylogin(chrname,chrpwd,tt);
		return true;
	});
	
	$("#fasong_shouji_submitblowline").click(function(){
		if(!$.checkMobilePhone($("#deal-buy-mobile-input").val()))
		{
			$.showErr("请输入正确的11位手机号码");
			$("#deal-buy-mobile-input").focus();
			return false;
		}
		var orderid=$("#deal-buy-orderid").val();
		var chrmobile=$("#deal-buy-mobile-input").val();
		submitblowquanmobile(orderid,chrmobile);
		return false;
	});	
	$("#header-subscribe-email").focus(function(){
		var obj=$("#header-subscribe-email");
		if(obj.val()=="输入Email，订阅每日团购信息"){
			obj.val("");
		}
	});	
	$("#header-subscribe-email").keyup(function(){
		var obj=$("#header-subscribe-email");
		if(obj.val().length>0){
			$("#header-subscribe-auto").show();
			$("#header-subscribe-auto").show();
			var str="<p class=\"email-title\">\u8bf7\u9009\u62e9\u60a8\u7684\u90ae\u7bb1\u7c7b\u578b...</p><ul class=\"email-list\">";
			str +="<li class='current' onmouseover=\"this.className='current';\" onmouseout=\"this.className='';\" >"+obj.val()+"</li>";
			var _fc=["163.com","gmail.com","qq.com","126.com","hotmail.com","sina.com","yahoo.com.cn","sohu.com","yahoo.cn","139.com"];
			var _e7,_e5;
			_e5=obj.val();
			_e7=_e5.indexOf("@");
			if(_e7!=-1){
				_e5=_e5.substr(0,_e7);
			}
			for(var i=0;i<_fc.length;i++){
				var _107=_fc[i];
				var _109=_e5+"@"+_107;
				str+="<li title=\""+_109+"\" onmouseover=\"this.className='current';\" onmouseout=\"this.className='';\" onclick=\"setHtml(this.innerHTML);\">"+_109+"</li>";
			}
			str +="</ul>";
			$("#header-subscribe-auto").html(str);
		
			$("body").one("click", function(){
				$("#header-subscribe-auto").hide();
			}); 
		}
		return false;
	});	
	$("#header-subscribe-form").submit(function(){
		var email=$("#header-subscribe-email").val();
		if(email.length == 0 || email=="输入Email，订阅每日团购信息")
		{
			alert("对不起，请输入您的 Email 地址！");
			$("#header-subscribe-email",this).focus();
			return false;
		}
		if(!$.checkEmail(email))
		{
			alert("对不起，您输入了错误的 Email 地址！");
			$("#header-subscribe-email",this).focus();
			return false;
		}
		var cityID=$("#topsubscribesitecityid").val();
		$.ajax({
			  url: baseurl+"request.aspx?action=ding&email="+email+"&cityid="+cityID,
			  cache: false,
			  success:function(data)
			  {
				if(data=="0"){
					var _df=$("#topsubscribesitecity").val();
					var dingemail=$("#topsubscribeemail").val();
					var _e2=getHelpType($("#header-subscribe-email").val());
					var innerHTML="<div id='email-subscribed-dialog'><div class=\"email-subscribed-dialog-c\"><h3><span id=\"email-subscribed-dialog-close\" class=\"close\" onclick=\"$('#topdialog').hide();$('#toppagemasker').hide();\">\u5173\u95ed</span></h3><div class=\"succ\"><p class=\"title\">\u90ae\u4ef6\u8ba2\u9605\u6210\u529f\uff01</p><p class=\"notice\">"+_df+"\u6bcf\u5929\u7684\u56e2\u8d2d\u5c06\u53ca\u65f6\u53d1\u5230\u60a8\u90ae\u7bb1</p></div><div class=\"setting\"><h4>\u60a8\u53ef\u80fd\u6536\u4e0d\u5230\u8ba2\u9605\u90ae\u4ef6...</h4><p class=\"text\">\u8bf7\u5c06 <strong>"+dingemail+"</strong> \u52a0\u5165\u90ae\u7bb1\u767d\u540d\u5355</p><a class=\"link\" href=\""+baseurl+"help/email/"+_e2+"/\" target=\"_blank\">\u7acb\u5373\u8fdb\u884c\u8bbe\u7f6e</a></div></div>";
					var dialog=$('#topdialog');
					dialog.html(innerHTML);
					var ew=340;var ww=jQuery(window).width();var lt=(ww/2-ew/2)+'px';var tp='20%';dialog.css('background-color','#FFF');dialog.css('left',lt);dialog.css('top',tp);dialog.css('z-index',9999);dialog.css('display','block');
					var height=jQuery('body').height()+'px';
					var width=jQuery(window).width()+'px';jQuery('#toppagemasker').css({'position':'absolute','z-index':'3000','width':width,'height':height,'filter':'alpha(opacity=0.2)','opacity':0.2,'top':0,'left':0,'background':'#000000','display':''});
				}
				else{
					alert(data);	
				}
			  }
		}); 
		return false;
	});	
	$("#header-subscribe-sms").click(function(){
		var _df=$("#topsubscribesitecity").val();
		var _116=$("#topsubscribesitecityid").val();
		var innerHTML="<div id='sms-subscribe-dialog'><h3 class=\"head\"><span class=\"close\" onclick=\"$('#topdialog').hide();$('#toppagemasker').hide();\">\u5173\u95ed</span></h3><div class=\"body\"><form id=\"sms-subscribe-form\" action=\"/mobilelist/subscribe\" method=\"post\" ><h4>\u77ed\u4fe1\u8ba2\u9605"+_df+"\u6bcf\u65e5\u56e2\u8d2d\u4fe1\u606f</h4><p class=\"mobile\"><label for=\"sms-subscribe-mobile\">\u624b\u673a\u53f7</label><input type=\"text\" id=\"sms-subscribe-mobile\" class=\"f-text\" maxlength=\"20\" name=\"sms-subscribe-mobile\" value=\"\" /><span class=\"tip\">\u8bf7\u8f93\u5165\u60a8\u7684\u624b\u673a\u53f7</span></p><p class=\"enter\"><label for=\"sms-subscribe-captcha\">\u9a8c\u8bc1\u7801</label><input type=\"text\" id=\"sms-subscribe-captcha\" class=\"f-text\" maxlength=\"20\" name=\"captcha\" /><span class=\"tip\">\u6309\u4e0b\u56fe\u5b57\u7b26\u586b\u5199\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199</span></p><p class=\"captcha cf\"><img id=\"sms-subscribe-captcha-img\" src=\""+baseurl+"image.aspx?"+Math.random()+"\"  /><span id=\"sms-subscribe-captcha-change\" onclick=\"document.getElementById('sms-subscribe-captcha-img').src=document.getElementById('sms-subscribe-captcha-img').src+'?';\">\u770b\u4e0d\u6e05\u695a\uff1f\u6362\u4e00\u5f20</span></p><p class=\"act\"><input type=\"hidden\" name=\"cityid\" value=\""+_116+"\" /><input type=\"button\" onclick=\"return subscribesmshead(this);\" class=\"commit\" value=\"\u53d1\u9001\" /></p></form></div></div>";
		var dialog=$('#topdialog');
		dialog.html(innerHTML);
		var ew=340;var ww=jQuery(window).width();var lt=(ww/2-ew/2)+'px';var tp='20%';dialog.css('background-color','#FFF');dialog.css('left',lt);dialog.css('top',tp);dialog.css('z-index',9999);dialog.css('display','block');
		var height=jQuery('body').height()+'px';
		var width=jQuery(window).width()+'px';jQuery('#toppagemasker').css({'position':'absolute','z-index':'3000','width':width,'height':height,'filter':'alpha(opacity=0.2)','opacity':0.2,'top':0,'left':0,'background':'#000000','display':''});
		
		return false;
	});	
	$("#header-tuiding-sms").click(function(){
		var _df=$("#topsubscribesitecity").val();
		var _116=$("#topsubscribesitecityid").val();
		var innerHTML="<div id='sms-subscribe-dialog'><h3 class=\"head\"><span class=\"close\" onclick=\"$('#topdialog').hide();$('#toppagemasker').hide();\">\u5173\u95ed</span></h3><div class=\"body\"><form id=\"sms-subscribe-form\" action=\"/mobilelist/subscribe\" method=\"post\" ><h4>取消短信订阅"+_df+"每日团购信息</h4><p class=\"mobile\"><label for=\"sms-subscribe-mobile\">\u624b\u673a\u53f7</label><input type=\"text\" id=\"sms-subscribe-mobile\" class=\"f-text\" maxlength=\"20\" name=\"sms-subscribe-mobile\" value=\"\" /><span class=\"tip\">\u8bf7\u8f93\u5165\u60a8\u7684\u624b\u673a\u53f7</span></p><p class=\"enter\"><label for=\"sms-subscribe-captcha\">\u9a8c\u8bc1\u7801</label><input type=\"text\" id=\"sms-subscribe-captcha\" class=\"f-text\" maxlength=\"20\" name=\"captcha\" /><span class=\"tip\">\u6309\u4e0b\u56fe\u5b57\u7b26\u586b\u5199\uff0c\u4e0d\u533a\u5206\u5927\u5c0f\u5199</span></p><p class=\"captcha cf\"><img id=\"sms-subscribe-captcha-img\" src=\""+baseurl+"image.aspx?"+Math.random()+"\"  /><span id=\"sms-subscribe-captcha-change\" onclick=\"document.getElementById('sms-subscribe-captcha-img').src=document.getElementById('sms-subscribe-captcha-img').src+'?';\">\u770b\u4e0d\u6e05\u695a\uff1f\u6362\u4e00\u5f20</span></p><p class=\"act\"><input type=\"hidden\" name=\"cityid\" value=\""+_116+"\" /><input type=\"button\" onclick=\"return tuisubscribesmshead(this);\" class=\"commit\" value=\"\u53d1\u9001\" /></p></form></div></div>";
		var dialog=$('#topdialog');
		dialog.html(innerHTML);
		var ew=340;var ww=jQuery(window).width();var lt=(ww/2-ew/2)+'px';var tp='20%';dialog.css('background-color','#FFF');dialog.css('left',lt);dialog.css('top',tp);dialog.css('z-index',9999);dialog.css('display','block');
		var height=jQuery('body').height()+'px';
		var width=jQuery(window).width()+'px';jQuery('#toppagemasker').css({'position':'absolute','z-index':'3000','width':width,'height':height,'filter':'alpha(opacity=0.2)','opacity':0.2,'top':0,'left':0,'background':'#000000','display':''});
		
		return false;
	});	
	$("#verify-coupon-id").click(function(){
		var _df=$("#topsubscribesitecity").val();
		var _116=$("#topsubscribesitecityid").val();
		var cname=$("#verify-name").html();
		var innerHTML="<div id='sms-quan-dialog'><h3 class=\"head\"><span class='title'>"+cname+"验证及消费登记</span><span class=\"close\" onclick=\"$('#topdialog').hide();$('#toppagemasker').hide();\">\u5173\u95ed</span></h3><div class=\"body\"><form id=\"sms-subscribe-form\"  method=\"post\"  style='margin:0;padding:0;'><p class=\"info\" id='quan-info'>请您输入"+cname+"编号和密码<br />进行操作（查询免输密码）</p><p class=\"mobile\"><label >"+cname+"编号：</label><input type=\"text\" id=\"sms-quan-chrcard\" class=\"f-text\" maxlength=\"20\" name=\"sms-quan-chrcard\" value=\"\" /><p class=\"enter\"><label>"+cname+"密码：</label><input type=\"text\" id=\"sms-quan-chrpwd\" class=\"f-text\" maxlength=\"20\" name=\"sms-quan-chrpwd\" /></p><p class=\"act\"><input type=\"button\" class=\"formbutton\" value=\"查询\" onclick=\"checkquansubmit1();\" />&nbsp;&nbsp;&nbsp;<input type=\"button\" class=\"formbutton\" value=\"消费 (需密码)\" onclick=\"checkquansubmit2()\" /></p><p></p></form></div></div>";
		var dialog=$('#topdialog');
		dialog.html(innerHTML);
		var ew=340;var ww=jQuery(window).width();var lt=(ww/2-ew/2)+'px';var tp='20%';dialog.css('background-color','#FFF');dialog.css('left',lt);dialog.css('top',tp);dialog.css('z-index',9999);dialog.css('display','block');
		var height=jQuery('body').height()+'px';
		var width=jQuery(window).width()+'px';jQuery('#toppagemasker').css({'position':'absolute','z-index':'3000','width':width,'height':height,'filter':'alpha(opacity=0.2)','opacity':0.2,'top':0,'left':0,'background':'#000000','display':''});
		
		return false;
	});	
	$("#commentsumit").click(function(){
		var chrtitle=$.trim($("#qusstion").val());
		var tuangouid=$.trim($("#tuangouid").val());
		if(chrtitle.length == 0)
		{
			$.showErr("请输入内容!");
			alert("请输入内容!");
			$("#qusstion").focus();
			return false;
		}
		submitcomment(chrtitle,tuangouid);
		return false;
	});	
});
function checkquansubmit2(){
	var cname=$("#verify-name").html();
	var chrcard=$("#sms-quan-chrcard").val();
	var chrpwd=$("#sms-quan-chrpwd").val();
	if(chrcard!="" && chrpwd!=""){
		if(confirm("每张"+cname+"只允许消费一次，您确定消费吗？")){
			$.ajax({
			  url: baseurl+"request.aspx?action=addquan&chrcard="+escape(chrcard)+"&chrpwd="+escape(chrpwd),
			  cache: false,
			  success:function(data)
			  {
				  var now=new Date(); 
					var year=now.getYear(); 
					var month=now.getMonth()+1; 
					var day=now.getDate(); 
					var hours=now.getHours(); 
					var minutes=now.getMinutes(); 
					var seconds=now.getSeconds(); 
				  if(data=="0"){
					$("#quan-info").html(cname+"编号密码不正确<br>本次消费失败");
				  }
				  else if(data=="1"){
					$("#quan-info").html(cname+"有效<br>消费时间："+year+"-"+ month+"-"+day+"  "+hours+":"+minutes+":"+seconds+"<br>本次消费成功");  
				  }
				  else{
					$("#quan-info").html(data);
				  }
			  }
			});		
		}
	}
}
function checkquansubmit1(){
	var chrcard=$("#sms-quan-chrcard").val();
	if(chrcard!=""){
		$.ajax({
		  url: baseurl+"request.aspx?action=checkquan&chrcard="+escape(chrcard),
		  cache: false,
		  success:function(data)
		  {
			$("#quan-info").html(data);
		  }
		});		
	}
}
function submitcomment(chrtitle,tuangouid){
	var url1=baseurl+"request.aspx?action=addcomment&chrtitle="+escape(chrtitle)+"&tuangouid="+escape(tuangouid);
	$.ajax({
		  url: url1,
		  cache: false,
		  success:function(data)
		  {
			if(data=="0"){
				$("#consult-add-succ").show();
				$("#consult-add-form").hide();
				return false;
			}
			else{
				alert(data);
				$.showErr(data);
				return false;
			}
		  }
	});	
}
function subscribesmshead(o){
	var _df=$("#topsubscribesitecity").val();
	var _116=$("#topsubscribesitecityid").val();
	var mobile=$("#sms-subscribe-mobile").val();
	var code=$("#sms-subscribe-captcha").val();
	if(mobile==""){
		alert("对不起，请输入手机号！");
		$("#sms-subscribe-mobile").focus();	
		return false;	
	}
	else{
		if(!$.checkMobilePhone(mobile))
		{
			alert("对不起，您输入了错误的 手机号！");
			$("#sms-subscribe-mobile").focus();	
			return false;
		} 	
	}
	if(code==""){
		alert("对不起，请输入验证码！");
		$("#sms-subscribe-captcha").focus();	
		return false;	
	}
	$.ajax({
		  url: baseurl+"request.aspx?action=send&email="+mobile+"&code="+code,
		  cache: false,
		  success:function(data)
		  {
			if(data=="0"){
				var innerHTML="<h4>\u77ed\u4fe1\u8ba2\u9605"+_df+"\u6bcf\u65e5\u56e2\u8d2d\u4fe1\u606f</h4><p class=\"noti\">\u8ba4\u8bc1\u7801\u5df2\u53d1\u9001\u5230\u60a8\u7684\u624b\u673a\uff1a<strong>"+mobile+"</strong></p><p class=\"verify cf\"><label for=\"sms-subscribe-verify\">\u8ba4\u8bc1\u7801</label><input type=\"text\" id=\"sms-subscribe-verify\" class=\"f-text\" maxlength=\"20\" name=\"code\" /><span class=\"tip\">\u8bf7\u8f93\u5165\u60a8\u6536\u5230\u7684\u8ba4\u8bc1\u7801\uff0c\u5b8c\u6210\u8ba2\u9605</span></p><p class=\"act\"><input type=\"hidden\" id='sms-subscribe-cityid' name=\"cityid\" value=\""+_116+"\" /><input type=\"hidden\" name=\"mobile\" value=\""+mobile+"\" id='sms-subscribe-mobile'/><input type=\"button\" class=\"commit confirm\" value=\"\u53d1\u9001\" onclick=\"return submitsmshead();\"/></p>";
				$("#sms-subscribe-form").html(innerHTML);
			}
			else{
				alert(data);
			}
		  }
	});	
	return false;
}
function tuisubscribesmshead(o){
	var _df=$("#topsubscribesitecity").val();
	var _116=$("#topsubscribesitecityid").val();
	var mobile=$("#sms-subscribe-mobile").val();
	var code=$("#sms-subscribe-captcha").val();
	if(mobile==""){
		alert("对不起，请输入手机号！");
		$("#sms-subscribe-mobile").focus();	
		return false;	
	}
	else{
		if(!$.checkMobilePhone(mobile))
		{
			alert("对不起，您输入了错误的 手机号！");
			$("#sms-subscribe-mobile").focus();	
			return false;
		} 	
	}
	if(code==""){
		alert("对不起，请输入验证码！");
		$("#sms-subscribe-captcha").focus();	
		return false;	
	}
	$.ajax({
		  url: baseurl+"request.aspx?action=sendtui&email="+mobile+"&code="+code+"&cityid="+_116,
		  cache: false,
		  success:function(data)
		  {
			if(data=="0"){
				var innerHTML="<h4>\取消短信订阅"+_df+"每日团购信息</h4><p class=\"noti\">\u8ba4\u8bc1\u7801\u5df2\u53d1\u9001\u5230\u60a8\u7684\u624b\u673a\uff1a<strong>"+mobile+"</strong></p><p class=\"verify cf\"><label for=\"sms-subscribe-verify\">\u8ba4\u8bc1\u7801</label><input type=\"text\" id=\"sms-subscribe-verify\" class=\"f-text\" maxlength=\"20\" name=\"code\" /><span class=\"tip\">请输入您收到的认证码，完成退订</span></p><p class=\"act\"><input type=\"hidden\" id='sms-subscribe-cityid' name=\"cityid\" value=\""+_116+"\" /><input type=\"hidden\" name=\"mobile\" value=\""+mobile+"\" id='sms-subscribe-mobile'/><input type=\"submit\" class=\"commit confirm\" value=\"\u53d1\u9001\" onclick=\"return tuisubmitsmshead();\"/></p>";
				$("#sms-subscribe-form").html(innerHTML);
			}
			else{
				alert(data);
			}
		  }
	});	
	return false;
}
function submitsmshead(){
	var chremail=$("#sms-subscribe-mobile").val();
	var cityID=$("#sms-subscribe-cityid").val();
	var code=$("#sms-subscribe-verify").val();
	$.ajax({
		  url: baseurl+"request.aspx?action=ding&email="+chremail+"&cityid="+cityID+"&chrcity=&typeid=1&code="+code,
		  cache: false,
		  success:function(data)
		  {
			if(data=="0"){
				var _df=$("#topsubscribesitecity").val();
				var innerHTML="<div class=\"succ\"><p class=\"title\">\u77ed\u4fe1\u8ba2\u9605\u6210\u529f\uff01</p><p class=\"notice\">"+_df+"\u6bcf\u5929\u7684\u56e2\u8d2d\u4fe1\u606f\u5c06\u53ca\u65f6\u53d1\u5230\u60a8\u624b\u673a</p></div><div class=\"alert\">温馨提示：收到订阅短信后，可以到网站取消订阅</div>";
				$("#sms-subscribe-form").html(innerHTML);
			}
			else{
				alert(data);
			}
		  }
	});	
	return false;
}
function tuisubmitsmshead(){
	var chremail=$("#sms-subscribe-mobile").val();
	var cityID=$("#sms-subscribe-cityid").val();
	var code=$("#sms-subscribe-verify").val();
	$.ajax({
		  url: baseurl+"request.aspx?action=tuiding&email="+chremail+"&cityid="+cityID+"&chrcity=&typeid=1&code="+code,
		  cache: false,
		  success:function(data)
		  {
			if(data=="0"){
				var _df=$("#topsubscribesitecity").val();
				var innerHTML="<div class=\"succ\"><p class=\"title\">取消短信订阅成功</p><p class=\"notice\"></p></div><div class=\"alert\">温馨提示：取消订阅成功，您以后将不会再收到我们的每日团购提示</div>";
				$("#sms-subscribe-form").html(innerHTML);
			}
			else{
				alert(data);
			}
		  }
	});	
	return false;
}
function getHelpType(_e5){
	var _e6={"163.com":"163","126.com":"126","gmail.com":"gmail","qq.com":"qq","vip.qq.com":"qq","foxmail.com":"qq","live.com":"live","live.cn":"live","hotmail.com":"live","yahoo.com.cn":"yahoo","yahoo.cn":"yahoo","sina.com":"sina","vip.sina.com":"sina","sohu.com":"sohu","139.com":"139"};
	var _e7,key;
	if(_e5){
		_e7=_e5.indexOf("@");
		if(_e7){
			key=_e5.substr(_e7+1);
			if(_e6[key]){
				return _e6[key];
			}
		}
	}
	return "other";
}
function setHtml(value){
	$("#header-subscribe-email").val(value);
}
function setshoujiyue(obj){
	var chremail=$("#dingyue2").val();
	var hid=$("#shoujidingyue2").val();
	if(hid==""){  //手机号还没输入进去的
		if(chremail=="" ||  chremail=="输入手机号，订阅每日秒货信息"){
			alert("对不起，请输入手机号，订阅每日秒货信息！");
			$("#dingyue2").focus();	
			return false;	
		}
		else{
			if(!$.checkMobilePhone(chremail))
			{
				alert("对不起，您输入了错误的 手机号！");
				$("#dingyue2").focus();	
				return false;
			} 	
		}
		$("#shoujidingyue2").val(chremail);
		sendmobilecode(chremail);
		obj.src=obj.src.replace("tinput2.jpg","tinput21.jpg");
	}
	else{  //判断输入的确认码对不对
		topdingyue(hid,"1",chremail);	
	}
	//topdingyue(chremail,"1");
}
function sendmobilecode(chremail){
	//window.open(baseurl+"request.aspx?action=send&email="+chremail);
	$.ajax({
		  url: baseurl+"request.aspx?action=send&email="+chremail,
		  cache: false,
		  success:function(data)
		  {
			if(data=="0"){
				$("#dingyue2").val("请输入您手机收到的确认码")
			}
			else{
				alert(data);
			}
		  }
	});	
}
function topdingyue(chremail,tt,code){
	var cityID=$("#subscribecityid").val();
	//window.open(  baseurl+"request.aspx?action=ding&email="+chremail+"&cityid="+cityID+"&chrcity=&typeid="+tt+"&code="+code  );
	$.ajax({
		  url: baseurl+"request.aspx?action=ding&email="+chremail+"&cityid="+cityID+"&chrcity=&typeid="+tt+"&code="+code,
		  cache: false,
		  success:function(data)
		  {
			if(data=="0"){
				document.getElementById("deal-subscribe-body").innerHTML="您手机已经成功订阅！";
				//window.location.href=window.location.href;
			}
			else{
				alert(data);
			}
		  }
	});	
}
function selectthis(obj){
	var joblist1 = $("#about-job-list").find(".job-title");
	var joblist2 = $("#about-job-list").find(".job-desc");
	for(var i=0;i<joblist1.length;i++)
	{
		if(obj ==joblist1[i]){
			if(joblist2[i].style.display=="" || joblist2[i].style.display=="none"){
				joblist2[i].style.display="block";	
				joblist1[i].className="job-title unfold";
			}
			else{
				joblist2[i].style.display="none";	
				joblist1[i].className="job-title fold";
			}
		}
	}
}
function checkcompanylogin(chrname,chrpwd,tt){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=checkcompanylogin&chrname="+escape(chrname)+"&chrpwd="+chrpwd+"&tt="+tt;
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestcheckcompanylogin;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestcheckcompanylogin()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					window.location.href=baseurl+"company/";
				}
				else{
					$.showErr(xmlhttp.responseText);
				}
			}
		}
	}	
}
function checkcompanyregister(chrname,chrpwd,chrcompany,chrtel){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=addcompany&chrname="+escape(chrname)+"&chrpwd="+chrpwd+"&chrcompany="+escape(chrcompany)+"&chrtel="+chrtel;
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestcheckcompanyregister;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestcheckcompanyregister()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					window.location.href=baseurl+"company/register.html?action=add";
				}
				else{
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}
function pointskeyup(obj){
	var _29=document.getElementById("account-points-tip");
	var _2c=parseInt($("#points_myjifen").val());
	var tip="提示：您的可用积分是"+_2c+"，兑换积分数不能大于您的可用积分！";
	if(obj.value>_2c){_29.innerHTML=tip;_29.style.visibility="visible";}else{_29.style.visibility="hidden";}
}
function chargekeyup(_28){
	var _29=document.getElementById("account-charge-tip");
	var _2c=500;var tip="\u63d0\u793a\uff1a\u5145\u503c\u91d1\u989d\u8d85\u51fa\u90e8\u5206\u94f6\u884c\u5355\u7b14\u652f\u4ed8\u989d\u5ea6\uff0c\u5efa\u8bae\u6bcf\u6b21\u5145\u503c\u5c0f\u4e8e499\u5143";
	if(_28.value>=_2c){_29.innerHTML=tip;_29.style.visibility="visible";}else{_29.style.visibility="hidden";}
}
function closeguide(){
	$("#sysmsg-guide").hide();										
}
function checkName(submitreturn)
{
	var _82=$("#address-name-error");
	var _83=$("#address-name");
	var _89="请正确填写姓名，最少不能低于2个字，最多不能超过15个字";
	if(!_83.val()||_83.val().length<2 || _83.val().length>15)
	{
		_82.html(_89);
		_82.show();
		return false;
	}
	else
	{
		_82.hide();
	}
}
function checkDetail()
{
	var _82=$("#address-detail-error");
	var _83=$("#address-detail");
	var _89="请填写街道地址，最少5个字，最多不能超过60个字，不能全部为数字";
	if(!_83.val()||_83.val().length<5 ||_83.val().length>60)
	{
		_82.html(_89);
		_82.show();
		return false;
	}
	else
	{
		_82.hide();
	}
}
function checkPhone(){
	var _82=$("#address-phone-error");
	var _83=$("#address-phone");
	var _89="电话号码不能少于6位";
	if(!_83.val()||!_83.val().match(/^.{6,}$/))
	{
		_82.html(_89);
		_82.show();
		return false;
	}
	else
	{
		_82.hide();
	}
}

function checkZipcode(){
	var _82=$("#address-district-error");
	var _83=$("#address-zipcode");
	var _89="邮政编码填写有误,请输入6位邮政编码";
	if(!_83.val()||!_83.val().match(/^\d{6}$/))
	{
		_82.html(_89);
		_82.show();
		return false;
	}
	else
	{
		_82.hide();
	}
}
function setzhuangtaibuy(id){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=showdeal&id="+escape(id);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsetzhuangtaibuy;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsetzhuangtaibuy()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				var output = xmlhttp.responseText;
				var tt=output.split('@@@');
				if(tt[0]!=""){
					$("#buylist_now").html("");
					$("#buylist_now").addClass("deal-price-expire")
					$("#showlisttime").html(tt[0]);
				}
				$("#showzhuangtai").html(tt[1]);
			}
		}
	}	
}
function checkpayform(){
	if($("#sys_errornum"))
	{
		var tt=$("#sys_errornum").html();
		if(tt!="" && tt!=null){
			alert(tt);
			$.showErr(tt);
			return false;
		}
	}
}
function sendCouponSMS(o,orderid,chrmobile,OID)
{
	var _84=o.parentNode.getElementsByTagName("form");
	if(_84.length){
		_84=_84[0];
	}
	else{
		
		_84=_makeCouponSMSForm(orderid,chrmobile,OID);
		o.parentNode.appendChild(_84);
	}
	if(_84.style.display=="none")
	{
		_84.style.display="block";
		_84.mobile.focus();
	}else{
		_84.style.display="none";
	}
	return false;
	
}
function sendblowSMS(o,orderid,chrmobile)
{
	var _84=o.parentNode.getElementsByTagName("form");
	if(_84.length){
		_84=_84[0];
	}
	else{
		_84=_makeblowSMSForm(orderid,chrmobile);
		o.parentNode.appendChild(_84);
	}
	if(_84.style.display=="none")
	{
		_84.style.display="block";
		_84.mobile.focus();
	}else{
		_84.style.display="none";
	}
	return false;
	
}
function _makeblowSMSForm(_72,_73){
	var _74=document.createElement("form");
	_73=_73?_73:"";
	_74.style.display="none";
	var _75="<div id='showdivmobile'><input type=\"text\" class=\"f-input\" name=\"mobile\" id='send_buy_quan' maxlength=\"11\" value=\""+_73+"\" autocomplete=\"off\" /><br /><input type=\"submit\" class=\"formbutton";
	_75+="\" value=\"\u53d1\u9001\" onclick=\"submitblowmobile('"+_72+"',this.form);return false;\"/></div><p id='showpmobile'></p>";
	_74.innerHTML=_75;
	document.body.appendChild(_74);
	var _76=getElementsByClassName("f-input","input",_74);
	var _77=getElementsByClassName("formbutton","input",_74);
	var div=_74.getElementsByTagName("div")[0];
	var p=_74.getElementsByTagName("p")[0];
	return _74;
}
function submitblowmobile(a,b){
	var chrmobile = b.mobile.value;
	var div=b.getElementsByTagName("div")[0];
	var p=b.getElementsByTagName("p")[0];
	if(!$.checkMobilePhone(chrmobile))
	{
		$.showErr("请输入正确的11位手机号码");
		b.focus();
		return false;
	}
	else{
		submitblowquanmobilesend(a,chrmobile,div,p);
	}
	return false;
}
function submitblowquanmobilesend(orderid,chrmobile,div,p){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	div.style.display="none";p.innerHTML="<img src=\""+baseurl+"template/default/images/indicator-large.gif\">";
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=blowmobile&orderid="+escape(orderid)+"&chrmobile="+escape(chrmobile);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitquanmobilesend;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitquanmobilesend()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					p.innerHTML="发送成功!";
					return false;
				}
				else if(xmlhttp.responseText=="1"){
					p.innerHTML="今天已发,不能再发!";
					return false;
				}
				else{
					$.showErr(xmlhttp.responseText);
					div.style.display="";
					p.style.display="none";
					return false;
				}
			}
		}
	}	
}
function getElementsByClassName(className,ttinput, parentElement){
	var elems = parentElement.getElementsByTagName(ttinput);
	var result=null;
	for (i=0; j=elems[i]; i++){
	  if ((" "+j.className+" ").indexOf(" "+className+" ")!=-1){
	   return j;
	  }
	}
	//return result;
} 

function _makeCouponSMSForm(_72,_73,OID){
	var _74=document.createElement("form");
	_73=_73?_73:"";
	_74.style.display="none";
	var _75="<div id='showdivmobile'><input type=\"text\" class=\"f-input\" name=\"mobile\" id='send_buy_quan' maxlength=\"11\" value=\""+_73+"\" autocomplete=\"off\" /><br /><input type=\"submit\" class=\"formbutton";
	_75+="\" value=\"\u53d1\u9001\" onclick=\"submitmobile('"+_72+"',this.form,'"+OID+"');return false;\"/></div><p id='showpmobile'></p>";
	_74.innerHTML=_75;
	document.body.appendChild(_74);
	var _76=getElementsByClassName("f-input","input",_74);
	var _77=getElementsByClassName("formbutton","input",_74);
	var div=_74.getElementsByTagName("div")[0];
	var p=_74.getElementsByTagName("p")[0];
	return _74;
}
function submitmobile(a,b,OID){
	var chrmobile = b.mobile.value;
	var div=b.getElementsByTagName("div")[0];
	var p=b.getElementsByTagName("p")[0];
	if(!$.checkMobilePhone(chrmobile))
	{
		$.showErr("请输入正确的11位手机号码");
		b.focus();
		return false;
	}
	else{
		submitquanmobilesend(a,chrmobile,div,p,OID);
	}
	return false;
}
function submitquanmobilesend(orderid,chrmobile,div,p,OID){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	div.style.display="none";p.innerHTML="<img src=\""+baseurl+"template/default/images/indicator-large.gif\">";
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=quanmobile&orderid="+escape(orderid)+"&chrmobile="+escape(chrmobile)+"&OID="+escape(OID);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitquanmobilesend;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitquanmobilesend()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					p.innerHTML="发送成功!";
					return false;
				}
				else if(xmlhttp.responseText=="1"){
					p.innerHTML="今天已发,不能再发!";
					return false;
				}
				else{
					$.showErr(xmlhttp.responseText);
					div.style.display="";
					p.style.display="none";
					return false;
				}
			}
		}
	}	
}

function submitblowquanmobile(orderid,chrmobile){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=blowmobile&orderid="+escape(orderid)+"&chrmobile="+escape(chrmobile);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitquanmobile;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitquanmobile()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					$("#fasongresult").html("手机短信发送成功！");
					alert("手机短信发送成功！");
					return false;
				}
				else{
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}

function submitquanmobile(orderid,chrmobile){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=quanmobile&orderid="+escape(orderid)+"&chrmobile="+escape(chrmobile);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitquanmobile;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitquanmobile()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					$("#fasongresult").html("手机短信发送成功！");
					alert("手机短信发送成功！");
					return false;
				}
				else{
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}
function submitchrmobileorder(orderid,chrmobile){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=addordermobile&orderid="+escape(orderid)+"&chrmobile="+escape(chrmobile);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitchrmobileorder;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitchrmobileorder()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				
				if(xmlhttp.responseText=="0"){
					$("#order-return-mobile-p").html("提交成功，当团购成功您将收到我们的手机短信提醒！");
					return false;
				}
				else{
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}
function getOs()  
{  
   var OsObject = "";  
   if(navigator.userAgent.indexOf("MSIE")>0) {  
        return "MSIE";       //IE浏览器
   }
   if(isFirefox=navigator.userAgent.indexOf("Firefox")>0){  
        return "Firefox";     //Firefox浏览器
   }
   if(isSafari=navigator.userAgent.indexOf("Safari")>0) {  
        return "Safari";      //Safan浏览器
   }
   if(isCamino=navigator.userAgent.indexOf("Camino")>0){  
        return "Camino";   //Camino浏览器
   }
   if(isMozilla=navigator.userAgent.indexOf("Gecko/")>0){  
        return "Gecko";    //Gecko浏览器
   }  
}
function setsonghuofashi(){
	if($("input[name='shuohuostyleid']:checked").val()=="1"){
		$("#address-h3").hide();	
		$("#address-table").hide();	
		$("#delivery-h3").hide();	
		$("#delivery-type").hide();	
		$("#address-detail").val("");
	}
	else{
		$("#address-h3").show();	
		$("#address-table").show();	
		$("#delivery-h3").show();	
		$("#delivery-type").show();	
	}
	quantitykeyup();
}
function quantitykeyup(o){
	var quantitys = $(".order-table").find("#deal-buy-quantity-input");
	var detailsids = $(".order-table").find("#detailsid");
	var buyprices = $(".order-table").find("#deal-buy-price");
	var oldnums = $(".order-table").find("#oldvalue");
	var buytotals = $(".order-table").find("#deal-buy-total");
	var totalmoney=$("#deal-buy-total-t").html();
	var orderid=$("#orderid").val();
	var newjisuan=false;
	var listyoufeinum =parseFloat($("#deal-buy-delivery-num").html());
	var listyoufeimoney =parseFloat($("#deal-buy-delivery-money").html());
	var totalnums=0;
	if($("input[name='shuohuostyleid']:checked").val()=="1"){
		listyoufeimoney=0;
		listyoufeinum=0;
	}
	if (/[^\d]/.test(listyoufeimoney)){
		listyoufeimoney=0;
		listyoufeinum=0;
	}
	for(var i=0;i<quantitys.length;i++)
	{
		totalnums +=parseFloat(quantitys[i].value);
		if(typeof(o)=="undefined")
		{
			o=quantitys[0];
			newjisuan=true;
		}
	}
	for(var i=0;i<quantitys.length;i++)
	{
		if(o==quantitys[i]){
			if(o.value!=parseFloat(oldnums[i].value)  || newjisuan){
			var newmoney=parseFloat(o.value)*parseFloat(buyprices[i].innerHTML);
			var oldmoney=parseFloat(oldnums[i].value)*parseFloat(buyprices[i].innerHTML);
			var onemoney=parseFloat(buyprices[i].innerHTML);
			var yuer=$("#cardcode-row-t").html();
			var tmoney=$("#moneyall").val();
			var onetotal=buytotals[i];
			var oneoldnum=oldnums[i];
			var  Digital=new  Date();
			Digital=Digital+40000;
			var url=baseurl+"request.aspx?action=buy&detailsid="+escape(detailsids[i].value)+"&num="+escape(o.value)+"&id="+escape($("#buytuangouid").val())+"&orderid="+orderid;
			url=url+"&k="+Digital;
			var method = "post"; 
			var asynchronism = true //是否异步 
			function callBack(xml){
				if(xml.readyState==4)
				{
					if(xml.status==200)
					{
						if(xml.responseText=="0"){
							onetotal.innerHTML=ReturnCHA(parseFloat(o.value)*onemoney)
							oneoldnum.value=o.value;
							tmoney=ReturnCHA(parseFloat(tmoney)+parseFloat(newmoney)-parseFloat(oldmoney));
							$("#moneyall").val(ReturnCHA(tmoney));
							if(totalnums>=listyoufeinum || listyoufeimoney==0){
								$("#deal-buy-delivery-fee").html("0");
							}
							else{
								$("#deal-buy-delivery-fee").html(listyoufeimoney);
								tmoney +=listyoufeimoney;
							}
							totalmoney = ReturnCHA(tmoney); //-parseFloat(yuer)
							if(totalmoney<0){
								//totalmoney=0;
							}
							$("#deal-buy-total-t").html(totalmoney)
						}
						else{
							var output = xml.responseText;
							var odnv=oneoldnum.value;
							
							if(output.indexOf("@")!=-1){
								odnv=output.split("@")[1];
								output =output.split("@")[0];	
							}
							$.showErr(output);
							o.value=parseFloat(odnv);
							quantitykeyup(o)
						}
					}
				}
			} 
			new Ajax().ajaxRequest(baseurl+"request.aspx","action=buy&detailsid="+escape(detailsids[i].value)+"&num="+escape(o.value)+"&id="+escape($("#buytuangouid").val())+"&orderid="+orderid,method,asynchronism ,callBack); 
			}
		}
	}
}
function ReturnCHA(varNumber){
	if (varNumber.toFixed)
	{ 
		varNumber = varNumber.toFixed(2); 
	}
	else  //浏览器不支持toFixed()就使用其他方法
	{
		 var div = Math.pow(10,2);
		varNumber = Math.round(varNumber * div) / div;
	} 
	return parseFloat(varNumber);
}
function quantitykeydown(e){
	if(window.event) // IE
	{
	  k = e.keyCode
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
	  k = e.which
	}
	var k=event.keyCode;
	if(!(k==8 || k==9 || k==13 || k==17 || k==16 || k>=33 && k<=40 || k==45 || k==46 || k>=48 && k<=57 || k>=96 && k<=105))
	{
		return false;
	}
}
function submitcreditcard(shu){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=card&shu="+escape(shu);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitcreditcard;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitcreditcard()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				var output=xmlhttp.responseText;
				var sp=output.split("@@");
				if(document.getElementById("credit-card-notice")){
					if(output.indexOf("@@")!=-1){
						$("#cardcode-row-t").html(sp[0]);
						output="充值卡充值成功！充值卡金额：￥"+sp[1];
					}
					$("#credit-card-notice").show();
					document.getElementById("credit-card-notice").innerHTML=output;
					return false;
				}
				else{
					if(output.indexOf("@@")!=-1){
						$("#cardcode-row-t").html(sp[0]);
						var output="充值卡充值成功！充值卡金额：￥"+sp[1];
						$.showRight(output);
						return false;
					}
					else{
						$.showErr(xmlhttp.responseText);
						return false;
					}
				}
			}
		}
	}	
}
function submitfeedback(chrname,chrtel,chrmark,tt,othertel,cityid,chrcompany,leixing){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=feedback&chrname="+escape(chrname)+"&chrtel="+escape(chrtel)+"&chrmark="+escape(chrmark)+"&tt="+escape(tt)+"&othertel="+escape(othertel)+"&cityid="+escape(cityid)+"&chrcompany="+escape(chrcompany)+"&leixing="+escape(leixing);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitfeedback;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitfeedback()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					document.getElementById("feedbackdiv").innerHTML="<p class=\"notice\">提交成功，谢谢您的支持。 <a href=\""+baseurl+"\">&gt;&gt;返回首页</a></p>";
					return false;
				}
				else{
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}

function submiteditpwd(chrpwd,chrcode){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=editpwd&chrpwd="+escape(chrpwd)+"&chrcode="+chrcode;
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmiteditpwd;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmiteditpwd()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					//$.showRight("操作成功!");
					document.getElementById("resetpwddiv").innerHTML="<p class=\"notice\">操作成功！请<a href=\""+baseurl+"account/login/\">点击这里</a>登录。</p>";
					return false;
				}
				else{
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}
function submitforpwd(chremail){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=forpwd&chremail="+escape(chremail);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitforpwd;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitforpwd()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					$.showRight("操作成功!");
					document.getElementById("forgetform").innerHTML="<p class=\"notice\">操作成功！请到 <strong>"+chremail+"</strong> 查阅邮件，点击邮件中的链接重设您的密码。</p>";
					return false;
				}
				else{
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}
function submitrequest(chrtitle,styleid){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=adddayi&chrtitle="+escape(chrtitle)+"&styleid="+escape(styleid);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestsubmitrequest;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestsubmitrequest()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					$("#consult-add-succ").show();
					$("#consult-add-form").hide();
					return false;
				}
				else{
					alert(xmlhttp.responseText);
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}

function changepwd(chrname,chrmobile,chrpwd,ziduan1,ziduan2,ziduan3,ziduan4,ziduan5){
	var xmlhttp=createxmlhttp();
	if(!xmlhttp)
	{
		alert("你的浏览器不支持XMLHTTP！！");
		return;
	}
	var  Digital=new  Date();
	Digital=Digital+40000;
	var url=baseurl+"request.aspx?action=edit&chrmobile="+escape(chrmobile)+"&chrpwd="+chrpwd+"&chrname="+escape(chrname);
	url +="&ziduan1="+escape(ziduan1)+"&ziduan2="+escape(ziduan2)+"&ziduan3="+escape(ziduan3)+"&ziduan4="+escape(ziduan4)+"&ziduan5="+escape(ziduan5);
	url=url+"&k="+Digital;
	xmlhttp.onreadystatechange=requestchangepwd;
	xmlhttp.open("GET",url,true);
	xmlhttp.send(null);
	function requestchangepwd()
	{
		if(xmlhttp.readyState==4)
		{
			if(xmlhttp.status==200)
			{
				if(xmlhttp.responseText=="0"){
					$.showRight("操作成功!");
				}
				else{
					$.showErr(xmlhttp.responseText);
					return false;
				}
			}
		}
	}	
}
//function checkregister(chremail,cityid,chrcity,chrpwd,chrname,tt,ziduan1,ziduan2,ziduan3,ziduan4,ziduan5){
//	var xmlhttp=createxmlhttp();
//	if(!xmlhttp)
//	{
//		alert("你的浏览器不支持XMLHTTP！！");
//		return;
//	}
//	var  Digital=new  Date();
//	Digital=Digital+40000;
//	var url=baseurl+"request.aspx?action=add&chremail="+escape(chremail)+"&cityid="+cityid+"&chrcity="+escape(chrcity)+"&chrpwd="+chrpwd+"&chrname="+escape(chrname)+"&tt="+tt;
//	url +="&ziduan1="+escape(ziduan1)+"&ziduan2="+escape(ziduan2)+"&ziduan3="+escape(ziduan3)+"&ziduan4="+escape(ziduan4)+"&ziduan5="+escape(ziduan5);
//	url=url+"&k="+Digital;
//	xmlhttp.onreadystatechange=requestcheckregiseter;
//	xmlhttp.open("GET",url,true);
//	xmlhttp.send(null);
//	function requestcheckregiseter()
//	{
//		if(xmlhttp.readyState==4)
//		{
//			if(xmlhttp.status==200)
//			{
//				if(xmlhttp.responseText=="0"){
//					window.location.href=baseurl+"account/register.html?action=add&chremail="+chremail;
//				}
//				else if(xmlhttp.responseText=="1"){
//					alert("恭喜您，注册成功，现在就可以登录体验超低的团购！");
//					window.location.href=baseurl+"account/login/";
//				}
//				else{
//					$.showErr(xmlhttp.responseText);
//					return false;
//				}
//			}
//		}
//	}	
//}
//function checklogin(chremail,chrpwd,tt,refurl){
//	var xmlhttp=createxmlhttp();
//	if(!xmlhttp)
//	{
//		alert("你的浏览器不支持XMLHTTP！！");
//		return;
//	}
//	var  Digital=new  Date();
//	Digital=Digital+40000;
//	var url=baseurl+"request.aspx?action=checklogin&chremail="+escape(chremail)+"&chrpwd="+chrpwd+"&tt="+tt;
//	url=url+"&k="+Digital;
//	xmlhttp.onreadystatechange=requestchecklogin;
//	xmlhttp.open("GET",url,true);
//	xmlhttp.send(null);
//	function requestchecklogin()
//	{
//		if(xmlhttp.readyState==4)
//		{
//			if(xmlhttp.status==200)
//			{
//				if(xmlhttp.responseText=="0"){
//					var   f=document.createElement("IFRAME")   
//					f.height=0;   
//					f.width=0;  
//					var tturl=baseurl+"request.aspx?action=other";
//					f.src=tturl;  
//					document.body.appendChild(f);  
//					if(refurl.indexOf("order/check/")!=-1){
//						refurl =refurl.replace("check/","check/"+$("#buytuangouid").val()+"/");
//					}
//					setTimeout("shownewlogin('"+refurl+"')",3000);
//				}
//				else{
//					$.showErr(xmlhttp.responseText);
//					if($("#buytuangouid").val()!="1")
//					{
//						return false;
//					}
//				}
//			}
//		}
//	}	
//}
function shownewlogin(refurl){
	window.location.href=refurl;
}
function settruevalue(tt,obj){
	if(document.getElementById(obj))
	{
		if(tt){
			document.getElementById(obj).className="f-text"
			document.getElementById(obj).disabled=false;
		}	
		else{
			document.getElementById(obj).disabled=true;	
			document.getElementById(obj).className="f-text disabled"
		}
	}
}

function setradiovalue(tt,obj,num){
	for(var i=1;i<=num;i++){
		var newobj="text-"+obj+"-"+i;
		if(document.getElementById(newobj))
		{
			document.getElementById(newobj).disabled=true;	
			document.getElementById(newobj).className="f-text disabled"
		}
		if(tt==i){
			if(document.getElementById(newobj))
			{
				document.getElementById(newobj).className="f-text"
				document.getElementById(newobj).disabled=false;
			}
		}
	}

}
function setcss(aa,bb,cc){
	if(cc=="1"){
		var obj="vote-list-"+(parseInt(aa)+1)+"";
		if(document.getElementById(obj))
		{
			if(bb==0){
				document.getElementById(obj).style.display=""
			}
			else{
				document.getElementById(obj).style.display="none";
			}
		}
	}
}

function shareQQ(id)
{
    $("#"+id).toggle("slow");
}

function copyShareUrl(id)
{
try
{
    id = "#"+id;
    
    var txt = $(id).val();
		if(window.clipboardData)
		{
			window.clipboardData.clearData();
			var judge = window.clipboardData.setData("Text", txt);
			if(judge === true)
				alert("复制成功,你可以粘帖到QQ或者MSN的中发给好友！");
			else
				alert("不允许复制，请您手动进行");
		}
		else if(navigator.userAgent.indexOf("Opera") != -1)
		{
			window.location = txt;
		} 
		else if (window.netscape) 
		{
			try
			{
				netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
			}
			catch(e)
			{
				alert("被浏览器拒绝！\n请在浏览器地址栏输入'about:config'并回车\n然后将'signed.applets.codebase_principal_support'设置为'true'");
			}
			var clip = Components.classes['@mozilla.org/widget/clipboard;1'].createInstance(Components.interfaces.nsIClipboard);
			if (!clip)
				return;
			var trans = Components.classes['@mozilla.org/widget/transferable;1'].createInstance(Components.interfaces.nsITransferable);
			if (!trans)
				return;
			trans.addDataFlavor('text/unicode');
			var str = new Object();
			var len = new Object();
			var str = Components.classes["@mozilla.org/supports-string;1"].createInstance(Components.interfaces.nsISupportsString);
			var copytext = txt;
			str.data = copytext;
			trans.setTransferData("text/unicode",str,copytext.length*2);
			var clipid = Components.interfaces.nsIClipboard;
			if (!clip)
				return false;
			clip.setData(trans,null,clipid.kGlobalClipboard);
			alert("复制成功,你可以粘帖到QQ或者MSN的中发给好友！");
		}
		}
		catch(e)
		{}
}

